package com.smartguard.bean;

import java.util.ArrayList;
import java.util.List;

import com.alibaba.fastjson.JSONArray;
import com.mongodb.BasicDBList;

public class Device {
	private String deviceName;	//设备名
	private String deviceHash;	//设备哈希，相当于ID
	private String username;	//设备所属用户的用户名
	
	private Boolean isSensor;		//该设备是否感应加速度
	private Boolean isKey;			//该设备是否为钥匙端
	
	/**
	 * [{"事件类型":"name","触发设备":"设备的hash id"},{"事件类型":"name","触发设备":"设备的hash id"}]
	 * 
	 */
	private BasicDBList eventArray;	//事件触发设备的列表
	
	//TODO jinchuyang begin
	private Boolean isOnline; //是否在线
	private Double remaindPower;//剩余电量
	

	public Boolean getIsOnline() {
		return isOnline;
	}
	public void setIsOnline(Boolean isOnline) {
		this.isOnline = isOnline;
	}
	public Double getRemaindPower() {
		return remaindPower;
	}
	public void setRemaindPower(Double remaindPower) {
		this.remaindPower = remaindPower;
	}
	//TODO 金初阳 end
	public String getDeviceName() {
		return deviceName;
	}
	public void setDeviceName(String deviceName) {
		this.deviceName = deviceName;
	}
	public String getDeviceHash() {
		return deviceHash;
	}
	public void setDeviceHash(String deviceHash) {
		this.deviceHash = deviceHash;
	}
	public String getUsername() {
		return username;
	}
	public void setUsername(String username) {
		this.username = username;
	}
	public BasicDBList getEventArray() {
		return eventArray;
	}
	public void setEventArray(BasicDBList eventArray) {
		this.eventArray = eventArray;
	}
	
	public Boolean getIsSensor() {
		return isSensor;
	}
	public void setIsSensor(Boolean isSensor) {
		this.isSensor = isSensor;
	}

	public Boolean getIsKey() {
		return isKey;
	}
	public void setIsKey(Boolean isKey) {
		this.isKey = isKey;
	}
	/**
	 * 覆盖Object的equals方法，在设备列表等多处可能会用到
	 */
	@Override
	public boolean equals(Object object){
		if(object == null) return false;
		else if(object instanceof Device){
			return ((Device)object).getDeviceHash().equals(this.getDeviceHash());
		}
		else return false;
	}
	
	/**
	 * 覆盖Object的hashCode方法，在设备列表等多处可能会用到
	 */
	@Override
	public int hashCode(){
		return this.getDeviceHash().hashCode();
	}
	
	public static void main(String[] args){
		
	}
	
}
